package {
import kgame5.kutil.T;

import com.kgame5.xtank3d.app.AppFacade;

import flash.display.MovieClip;

/**
 * @author kk
 * 一个实验环境，测试鼠标3d用
 * 快速做出一个实验室环境，实验新式引擎
 * 1,先快速实现，然后重构，目标是坦克大战。实验室。
 * 
 * 这个在pureMVC中可以做为一个Mediator的comp,因为他可以接收命令，并向mediator发送事件
 */
[SWF(width="760",height="600",backgroundColor="0x000000",frameRate="20")]
public class KMain extends MovieClip{
	
	//这么写只是为了引入定义而已
	public function startup(mc_skin:MovieClip) {
		T.p(this,"startUp",mc_skin);
		AppFacade.getInstance().startup(mc_skin);
	}
	
//	//接收坦克的死亡的事件
//	public static const EVENTTYPE_TANK_DIE:String="EVENTTYPE_TANK_DIE";//接收GamePlay发来的
//	public static const EVENTTYPE_TANK_ADD_TANK:String="EVENTTYPE_TANK_ADD_TANK";
//	
//	
//	private var gamePlay:GamePlayX;//游戏核心
//	private var levelManager:LevelManager;//关卡管理器
//	private var stateID:int;//1是loading,2是游戏中
//	
//	public function KMain(){
//		
//		//this.mouseEnabled=false;
//		//this.mouseChildren=false;
//		
//		gamePlay=new GamePlayX(this, C.STAGE_WIDTH, C.STAGE_HEIGHT, C.FRAME_RATE, false);
//		levelManager=new LevelManager();
//		
//		gamePlay.addEventListener(EVENTTYPE_TANK_DIE, onGamePlay_tankDie);
//		levelManager.addEventListener(EVENTTYPE_TANK_ADD_TANK, onLevelManager_addNPCTank);
//		levelManager.addEventListener(LevelManager.EVENTTYPE_NEW_CORPS, onLevelManager_newCorps);
//		levelManager.addEventListener(LevelManager.EVENTTYPE_MISSION_COMPLETE, onLevelManager_missionComplete);
//		
//		
//		this.addEventListener(Event.ENTER_FRAME, efh);
//		
//		this.gotoState_Loading();
//	}
//	private function efh(e:Event):void{
//		switch(stateID){
//			case 1:
//			updateState_Loading();
//			break;
//			case 2:
//			updateState_Play();
//			break;
//		}
//	}
//	
//	//收到levelManger发事件可以添加坦克
//	private function onLevelManager_addNPCTank(e:KEvent):void{
//		gamePlay.executeCommand(AddNPCTankCommand.NAME, e.info);
//	}
//	
//	private function onLevelManager_newCorps(e:KEvent):void{
//		var corpsVO:CorpsVO=e.info as CorpsVO;
//		T.p("!!动画提示新军团出现",corpsVO.name);
//	}
//	
//	private function onLevelManager_missionComplete(e:KEvent):void{
//		T.p("战斗结束！");
//	}
//	
//	//坦克死亡
//	private function onGamePlay_tankDie(e:KEvent):void{
//		levelManager.onTankDie(e.info as MyTankVO);
//	}
//	
//	//加载
//	private function gotoState_Loading():void{
//		stateID=1;
//		ResourceManagerX.getInstance().start(10);
//	}
//	private function updateState_Loading():void{
//		//trace(ResLib.getInstance().getLoadingTip(),ResLib.getInstance().getProgress100());
//		if(ResourceManagerX.getInstance().isOK()){
//			T.p("完毕");
//			this.gotoState_Play();
//		}
//	}
//	
//	//播放
//	private function gotoState_Play():void{
//		
//		this.removeEventListener(Event.ENTER_FRAME, efh);
//		
//		stateID=2;
//		
//		//注册command
//		gamePlay.registerCommand(TankReqFireShotCommand.NAME, new TankReqFireShotCommand());
//		gamePlay.registerCommand(ShotBlastCommand.NAME, new ShotBlastCommand());
//		gamePlay.registerCommand(CartBlastCommand.NAME, new CartBlastCommand());
//		
//		gamePlay.registerCommand(AddTankCommand.NAME, new AddTankCommand());
//		gamePlay.registerCommand(AddNPCTankCommand.NAME, new AddNPCTankCommand());
//		gamePlay.registerCommand(AddShotCommand.NAME, new AddShotCommand());
//		gamePlay.registerCommand(RemoveEntityCommand.NAME, new RemoveEntityCommand());
//		
//		gamePlay.registerCommand(BlastChainCommand.NAME, new BlastChainCommand());
//		gamePlay.registerCommand(CartBlastCommand.NAME, new CartBlastCommand());
//		
//		//添加entity
//		var mapVO:MapVO=ResourceManagerX.getInstance().getMapVO();
//		var groundVO:GroundVO=mapVO.groundVO;
//		gamePlay.startup(groundVO.CC, groundVO.RC, groundVO.CellSize);//开始之前必须先执行这个
//		
//		//摄像机
//		gamePlay.addEntity(new MyCameraEntity(groundVO.Width, groundVO.Height));
//		
//		//地面
//		gamePlay.addEntity(new GroundEntity(groundVO));
//		
//		//障碍物
//		for each(var blockVO:BlockVO in mapVO.dict_barVO){
//			gamePlay.addEntity(new BlockEntity(blockVO));
//		}
//		
//		//关卡管理器
//		levelManager.start(ResourceManagerX.getInstance().getLevelVO());
//		
//		//自己坦克.注意这个要放在start的后面，因为需要填充数据
//		var myTankVO:MyTankVO=levelManager.createMyTankVO(1);
//		myTankVO.name="鸟の诗";
//		gamePlay.executeCommand(AddTankCommand.NAME, myTankVO);
//		
//	}
//	
//	private function updateState_Play():void{
//		
//	}
//	
	//添加背景
}//end of class
}
